package com.aigou.compont;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.aigou.pojo.Order;
import com.aigou.service.GoodsService;
import com.aigou.service.IOrderService;

@Component
public class GoodsStatusService {

	@Autowired
	IOrderService orderService;
	@Autowired
	GoodsService goodsService;

	@RabbitListener(queues = { "order_queue" })
	public void updateStatus(String orderId) {
		
		Order order = orderService.getById(orderId);
		LocalDateTime now = LocalDateTime.now();
		// 11:48:00 < 11:47:10 + 1分钟
		// 修改状态
		order.setStatus(3);
		order.setPayStatus(2);
		// update(order);
		// 更新订单状态
		orderService.updateById(order);
		// 回退商品数量
		// TODO 修改定时任务
		//goodsService.addKuCun(order.getGid(), order.getNum());
		// 回退优惠金额
		
	}

}
